<template>
  <div class="big">
    <div class="header">
      <span class="iconfont icon-chaye"></span>
      <slot>
        <div class="search" @click="goSearch()">
          <span class="iconfont icon-fangdajing"></span>
          <span>搜你喜欢的...</span>
        </div>
      </slot>

      <span class="iconfont icon-kefu"></span>
    </div>
    <van-tabs class="tab" v-model:active="active" @change="onClickTab">
      <template v-for="(item, index) in tarbar">
        <van-tab :title="item.label" :key="index"></van-tab>
      </template>
    </van-tabs>
  </div>
</template>

<script>
import axios from "axios";

export default {
  props: ["tarbar"],
  data() {
    return {
      active: 0,
    };
  },
  methods: {
    onClickTab(index) {
      axios({
        url: `/api/index_list/${index}/data/1`,
      }).then((res) => {
        if(index==0){
            this.$emit('changeNewData',res.data.data.data)
        }else{
          this.$emit('changeNewData',res.data.data)
        }      
      });

      
    },
    goSearch(){
        this.$router.push('/search')
      }
  },
};
</script>

<style  scoped  lang='scss'>
.van-tabs__line {
  background-color: #b0352f;
}
.van-tab--active {
  color: #b0352f;
}
.van-tabs__wrap--scrollable .van-tab {
  padding: 0 16px;
}
.van-tab {
  font-size: 0.4rem;
}
.van-tabs--line .van-tabs__wrap {
  height: 1.0732rem;
}
.big {
}

.header {
  width: 100vw;
  height: 1.0732rem;
  background-color: #b0352f;
  display: flex;
  color: white;
  align-items: center;
  justify-content: space-between;

  .iconfont {
    flex: 1;
    text-align: center;
    font-size: 0.5854rem;
  }
}
.search {
  width: 6.9512rem;
  height: 0.7317rem;
  background-color: white;
  border-radius: 99px;
  color: #222;
  font-size: 0.3415rem;
  display: flex;
  align-items: center;
  .iconfont {
    flex: none;
    font-size: 0.415rem;
    padding: 0 2vw;
  }
}
</style>